package com.bjxst;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

public class ObjectOutputStreamObjectTypeDemo02 {
    public static void main(String[] args) {
        ObjectOutputStream oos = null;
        try{
            oos = new ObjectOutputStream(new FileOutputStream("d:/x2.txt"));
            //创建实体对象
            Users02 users02 = new Users02(1,"hai","32");
            //把内容写入文件，序列化
            oos.writeObject(users02);
            oos.flush();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                if(oos != null){
                    oos.close();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
